<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function foo(a,b){
            console.log(b);
            return {
                foo:function(c){
                    return foo(c,a);
                }
            }
        }
        var func1 = foo(0);//undefined
        func1.foo(1);//0
        func1.foo(2);//0
        func1.foo(3);//0
        var func2 = foo(0).foo(1).foo(2).foo(3);//undefined//0//1//2
        var func3 = foo(0).foo(1);//undefined//0
        func3.foo(2);//1
        func3.foo(3);//1
        function createe(a){
            var map = {
                cat: function(){
                    console.log(a++);
                }
            }
            return map;
        }
        var cat = createe(2);
        cat.cat();
        cat.cat();
        var bat = createe(6);
        bat.cat();
    </script>
</body>
</html>